package com.rainman.noswagger.core;

import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.comments.Comment;
import com.github.javaparser.ast.expr.AnnotationExpr;
import com.rainman.noswagger.NoSwaggerCore;
import com.rainman.noswagger.info_bean.AnnoInfoBean;
import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;

@Data
public class BaseBean {

    private String name;
    private NoSwaggerCore core;

    private String oriCommentStr;
    private List<AnnoInfoBean> annoInfoBeanList;
    private HashMap<String,Object> otherInfo;

    public BaseBean(){
        annoInfoBeanList=new ArrayList<>();
        otherInfo=new HashMap<>();
    }

    public BaseBean(String name, NoSwaggerCore core, NodeList<AnnotationExpr> annotations, Optional<Comment> comment){

        this();
        this.name=name;
        this.core=core;

        if(comment!=null){
            comment.ifPresent(value -> this.oriCommentStr = value.getContent());
        }

        for(AnnotationExpr annotationExpr:annotations){
            annoInfoBeanList.add(new AnnoInfoBean(annotationExpr));
        }

    }

}
